﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Copy8DigitImagesFromProcessedFolder
{
    class Program
    {
        static void Main(string[] args)
        {
            string sourcePath = @"D:\netbyte\image_handler\images\processed\2013";
            string destPath = @"D:\Temp\8DigitImages";

            for (int i = 8; i < 9; i++ )
            {
                string source = sourcePath + "\\Week" + i;
                Console.WriteLine("Processing" + source);
                ProcessImagesFolder(destPath, source);
                Console.WriteLine("Week " + i + " completed!");
            }

                
        }

        private static void ProcessImagesFolder(string destPath, string sourcePath)
        {
            string[] files = Directory.GetFiles(sourcePath, "*.jpg", SearchOption.AllDirectories);
            foreach (string file in files)
            {
                string fileName = GetFileNameFromPath(file);
                if (fileName.Length == 13)
                {
                    string destination = destPath + "\\" + fileName;

                    File.Copy(file, destination, true);
                }
            }
        }

        private static string GetFileNameFromPath(string file)
        {
            return file.Substring(file.LastIndexOf("\\") + 1, file.Length - file.LastIndexOf("\\") - 1);
        }
    }
}
